\vsssub
\subsubsection{~Multi-grid modules} \label{sec:multi_mod}
\vsssub

The multi-grid wave model shel {\file ww3\_multi} provides a shell around the
basic wave model as described in the previous section. This shell manages the
side-by-side running of multiple wave model grids, and all communication
between the grids. To achieve this various additional modules have been
developed. At the core are the initialization, multi-grid model and
finalization routines.

\vspace{\baselineskip} \noindent
Initialization of multi-grid model \hfill {\file wminitmd.ftn}

\begin{flisti}
\fit{wminit}{Multi-grid model initialization.}
\end{flisti}

\noindent
Running of multi-grid model \hfill {\file wmwavemd.ftn}

\begin{flisti}
\fit{wmwave}{Multi-grid model execution.}
\fit{wmprnt}{Printing to log file.}
\fit{wmbcst}{Non-blocking MPI broadcast.}
\fit{wmwout}{Idem.}
\end{flisti}

\noindent
Finalizing of multi-grid model \hfill {\file wmfinlmd.ftn}

\begin{flisti}
\fit{wmfinl}{Multi-grid model finalization.}
\end{flisti}

\noindent
These routines are designed to become part of a coupled model. For the
structure of the actual wave model routine, reference is made to
\cite{tol:MMAB07b}. The resulting wave model driver {\file ww3\_multi}
consequently becomes extremely simple; it initializes the MPI environment,
and then calls the above three modules consecutively. 

The main multi-grid wave model routines require an expansion of the data
structure used by \ws. Furthermore, main activities are gathered in
subroutines in various modules.

\vspace{\baselineskip} \noindent
Data storage \hfill {\file wmmdatmd.ftn}

\begin{flisti}
\fit{wmndat}{Set number of grids to be considered.}
\fit{wmdimd, wmdimm}{}
\fit{      }{Set dimensions and allocate storage.}
\fit{wmsetm}{Set pointers to selected grid.}
\end{flisti}

\noindent
Determine grid relations \hfill {\file wmgridmd.ftn}

\begin{flisti}
\fit{wmglow}{Relations to lower ranked grids.}
\fit{wmghgh}{Relations to higher ranked grids.}
\fit{wmgeql}{Relations between equal ranked grids.}
\fit{wmrspc}{Determine need for spectral conversion between grids.}
\end{flisti}

\noindent
Update model input \hfill {\file wmupdtmd.ftn}

\begin{flisti}
\fit{wmupdt}{General input update routine.}
\fit{wmupd1}{Update input from native files using {\file w3fldsmd.ftn} from
             \para\ref{sec:aux_mod}.} 
\fit{wmupd2}{Update input from pore-defined input grids.}
\fit{wmupdv}{Update vector fields.}
\fit{wmupds}{Update scalar fields.}
\end{flisti}

\noindent
Perform internal communications \hfill {\file wminiomd.ftn}

\begin{flisti}
\fit{wmiobs}{Stage internal boundary data.}
\fit{wmiobg}{Gather internal boundary data.}
\fit{wmiobf}{Finalize {\F wmiobs} (MPI only).}
\fit{wmiohs}{Stage internal high to low rank data.}
\fit{wmiohg}{Gather internal high to low rank data.}
\fit{wmiohf}{Finalize {\F wmiohs} (MPI only).}
\fit{wmioes}{Stage internal data between equal ranked grids.}
\fit{wmioeg}{Gather internal data between equal ranked grids.}
\fit{wmioef}{Finalize {\F wmioes} (MPI only).}
\end{flisti}

\noindent
Unify point output to single file \hfill {\file wmiopomd.ftn}

\begin{flisti}
\fit{wmiopp}{Initialization routine.}  
\fit{wmiopo}{Data gather and write routine (using {\F w3iopo} in {\file
             w3iopomd.ftn}).}
\end{flisti}

\noindent
To complete the multi-grid wave model, one additional service module is
needed. For the actual contents of the service module see the documentation
in the source code files.

\begin{flist}
\fit{wmunitmd.ftn}{Dynamic unit number assignment}
\fit{wmscrpmd.ftn}{SCRIP utilities.}
\end{flist}
